#include "qopenharmonycamerasession.h"
#include "qopenharmonycameracontrol.h"

QT_BEGIN_NAMESPACE

QOPenHarmonyCameraControl::QOPenHarmonyCameraControl(QOPenHarmonyCameraSession *session)
    : QCameraControl(Q_NULLPTR)
      , m_cameraSession(session)
{
    connect(m_cameraSession, SIGNAL(statusChanged(QCamera::Status)),
            this, SIGNAL(statusChanged(QCamera::Status)));

    connect(m_cameraSession, SIGNAL(stateChanged(QCamera::State)),
            this, SIGNAL(stateChanged(QCamera::State)));

    connect(m_cameraSession, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString)));

    connect(m_cameraSession, SIGNAL(captureModeChanged(QCamera::CaptureModes)),
            this, SIGNAL(captureModeChanged(QCamera::CaptureModes)));
}

QOPenHarmonyCameraControl::~QOPenHarmonyCameraControl()
{

}

QCamera::CaptureModes QOPenHarmonyCameraControl::captureMode() const
{
    return m_cameraSession->captureMode();
}

void QOPenHarmonyCameraControl::setCaptureMode(QCamera::CaptureModes mode)
{
    m_cameraSession->setCaptureMode(mode);
}

bool QOPenHarmonyCameraControl::isCaptureModeSupported(QCamera::CaptureModes mode) const
{
    return m_cameraSession->isCaptureModeSupported(mode);
}

void QOPenHarmonyCameraControl::setState(QCamera::State state)
{
    m_cameraSession->setState(state);
}

QCamera::State QOPenHarmonyCameraControl::state() const
{
    return m_cameraSession->state();
}

QCamera::Status QOPenHarmonyCameraControl::status() const
{
    return m_cameraSession->status();
}

bool QOPenHarmonyCameraControl::canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const
{
    Q_UNUSED(status);

    switch (changeType) {
    case QCameraControl::CaptureMode:
    case QCameraControl::ImageEncodingSettings:
    case QCameraControl::VideoEncodingSettings:
    case QCameraControl::Viewfinder:
        return true;
    default:
        return false;
    }
}

QT_END_NAMESPACE
